package com.dream.style.app.ac;

import android.annotation.TargetApi;
import android.app.Activity;
import android.content.Intent;
import android.graphics.Color;
import android.os.Build;
import android.os.Bundle;
import android.view.View;
import android.widget.Toast;

import com.dream.style.R;
import com.dream.style.app.ac.acc.ChangePswActivity;
import com.dream.style.app.view.MyTabBar;

/**
 * @Created by lincyu
 * @Time: 2018/11/13 15:46
 * @Decs: 类
 */
public class KztActivity extends Activity {

    @Override
    protected void onCreate(Bundle savedInstanceState) {
        super.onCreate(savedInstanceState);
        initView();
    }
    private void initView() {
        // 布局
        setContentView(R.layout.activity_kzt);
        // 导航栏
        initTarBar();
        //

    }

    private void start(Class s){
        Intent i = new Intent(this,s);
        startActivity(i);
    }

    MyTabBar mTabBar;
    final String[]  mTabBarTitle = {
        "ic_main_shouye", "ic_main_dingdan" , "直播", "消息", "我的"
    };
    // 正常
    private int[] mTabBarImageNoSelected = new int[]{
            R.drawable.shouye,
            R.drawable.quanbudingdan,
            R.drawable.zhibo,
            R.drawable.xiaoxi,
            R.drawable.geren
    };

    // 选中
    private int[] mTabBarImageSelected = {
            R.drawable.shouye_,
            R.drawable.quanbudingdan_,
            R.drawable.zhibo_,
            R.drawable.xiaoxi_,
            R.drawable.geren_
    };


    @TargetApi(Build.VERSION_CODES.O)
    private void initTarBar() {
        mTabBar  = findViewById(R.id.kzt_myTarBar);
        if (mTabBar==null){
            Toast.makeText(this,"mTarBar找不到！",
                    Toast.LENGTH_SHORT).show();
            return;
        }
        mTabBar
                // 设置背景图片
                .setTabBackgroundColor(Color.WHITE)
                // 选项卡默认状态颜色
                .setTabColorNormal(Color.BLACK)
                // 选项卡选中状态颜色
                .setTabColorSelected(KztActivity.this.getResources().getColor(R.color.f_red))
                // 选项卡图标的宽高
                .setTabIconSize(25 ,25)
                // 选项卡中图标和文字的间距
                .setTabPaddingTextToIcon(2)
                // 选项卡区域的资源数据
                .setTabTitle(mTabBarTitle)
                .setTabNormalIconId(mTabBarImageNoSelected)
                .setTabSelectIconId(mTabBarImageSelected)
                // 选项卡设置点击事件// 也可以放在初始化事件那里进行处理
                .setOnTabClickLlistener(new MyTabBar.OnTabClickListener() {
                    @Override
                    public void onTabOnClick(int position) {
                        Toast.makeText(KztActivity.this,"您点击了"+mTabBarTitle[position],
                                Toast.LENGTH_SHORT).show();

                        TabBarEvent(position);
                    }
                })
                .commit();
    }

    // 处理底部事件
    private void TabBarEvent(int position) {

    }


    public interface Task {

    }

    /**
     * 沉浸式效果
     * @param hasFocus
     */
    @Override
    public void onWindowFocusChanged(boolean hasFocus) {
        super.onWindowFocusChanged(hasFocus);
        if (hasFocus && Build.VERSION.SDK_INT >= 19) {
            getWindow().getDecorView().setSystemUiVisibility(
                    View.SYSTEM_UI_FLAG_LAYOUT_STABLE
                            | View.SYSTEM_UI_FLAG_LAYOUT_HIDE_NAVIGATION
                            | View.SYSTEM_UI_FLAG_LAYOUT_FULLSCREEN
                            | View.SYSTEM_UI_FLAG_HIDE_NAVIGATION
                            | View.SYSTEM_UI_FLAG_FULLSCREEN
                            | View.SYSTEM_UI_FLAG_IMMERSIVE_STICKY);
        }
    }

}
